<?php
	/**
	 *  后台综合搜索控制器
	 */
	 class SearchController extends AuthController{
	 	
		/**
		 * 搜索商品
		 */
		public function ajaxGoods(){
			if(!IS_AJAX) $this->error('非法请求');
			$keywords = Q('post.keywords');
			$goods = K('Goods')->where("goods_name LIKE '%{$keywords}%' OR goods_sn LIKE '%{$keywords}%'")->all();
			$this->assign('goods',$goods);
			$this->ajax($this->display(null,-1,null,'text/html',false));
		}
		
		
		/**
		 * 搜索用户名
		 */
		 public function ajaxUser(){
		 	if(!IS_AJAX) $this->error('非法请求');
			$keywords = Q('post.keywords');
			$users = K('Users')->where("username LIKE '%{$keywords}%'")->all();
			$this->assign('users',$users);
			$this->ajax($this->display(null,-1,null,'text/html',false));
		 }
		
		/**
		 *  搜索订单
		 */
		 public function ajaxOrder(){
		 	if(!IS_AJAX) $this->error('非法请求');
			$keywords = Q('post.keywords');
//			p($keywords);
			$orderlists = K('GoodsOrder')->where("order_status LIKE '%{$keywords}%' OR order_sn LIKE '%{$keywords}%' OR take_man LIKE '%{$keywords}%' OR take_addr LIKE '%{$keywords}%'")->all();
			$this->assign('orderlists',$orderlists);
			$this->ajax($this->display(null,-1,null,'text/html',false));
		 }
		
		
	 }
	